<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class CI_check_users 
{
  
  
   function Check_session()
   {
      
    $CI =& get_instance();
    $CI->load->database();
	$displayform = '';
    $displayform .= '<br/>';
	$displayform .=$CI->check_users->is_alive();
	
	//echo $CI->check_users->is_alive();
	//$displayform .= print_r($id);
	return $displayform;
	
    
    $users = $CI->db->query("select user_id,user_name from tbl_users");
    
    $users_details = $users->result_array();
    
    $displayform = '';
    $displayform .= '<br/>';
    $displayform .='<table name="users_info" width=80% border=1>';
    $displayform .='<tr >';
    $displayform .='<td>';
    $displayform .='User Id';
    $displayform .='</td>';
    $displayform .='<td>';
    $displayform .='User Name';
    $displayform .='</td>';
    $displayform .='</tr>';
    
        foreach($users_details as $row)
        {
          
            $id = $CI->check_users->is_alive();
            
            if($id == $row['user_id'])
            {
              $displayform .='<tr>';
              $displayform .= '<td>';
              $displayform .= $row['user_id'];
              $displayform .='</td>';
              $displayform .='<td>';
              $displayform .= $row['user_name'];
              $displayform .='</td>';
              $displayform .='</tr>';
            }            
            
        }
        
        $displayform .='</table>';
        
        return $displayform;
	 
        
   }
  
   
   
   function is_alive()
   {
          $CI =& get_instance();
         $CI->load->library('session');
         $sess=$CI->session->userdata('userlogindetails');
         if($sess['user_group'] == 2)
         {
            return $sess['user_name']; 
         }
   }
   
   
  // function 
}
